#pragma once

#include "protocol.hpp"

class onliecal
{
public:
    Response Deal(Request &req)
    {
        Response ret(0, 0);
        switch (req.Oper())
        {
        case '+':
        {
            ret.Result(req.X() + req.Y());
            ret.Code(0);
            break;
        }
        case '-':
        {
            ret.Result(req.X() - req.Y());
            ret.Code(0);
            break;
        }
        case '*':
        {
            ret.Result(req.X() * req.Y());
            ret.Code(0);
            break;
        }
        case '/':
        {
            if(req.Y() == 0){
                ret.Code(1);
                break;
            }
            ret.Result(req.X() / req.Y());
            ret.Code(0);
            break;
        }
        case '%':
        {
            if(req.Y() == 0){
                ret.Code(2);
                break;
            }
            ret.Result(req.X() % req.Y());
            ret.Code(0);
            break;
        }
        default:
            ret.Code(3);
            break;
        }
        return ret;
    }
};